﻿using Baidu.Api.Response;
using Baidu.Api.Util;
using System;
using System.Collections.Generic;
using System.Text;

namespace Baidu.Api.Request
{
    public class FileRapidUploadRequest : IBaiduRequest<FileRapidUploadResponse>
    {
        public string Path { get; set; }
        public ulong ContentLength { get; set; }
        public string ContentMD5 { get; set; }
        public string SliceMD5 { get; set; }
        public string ContentCrc32 { get; set; }
        public string Ondup { get; set; }

        #region IBaiduRequest

        public string GetObjectName()
        {
            return "pcs/file";
        }

        public string GetMethod()
        {
            return "rapidupload";
        }

        public IDictionary<string, string> GetFormParameters()
        {
            BaiduDictionary parameters = new BaiduDictionary();
            parameters.Add("path", this.Path);
            parameters.Add("content-length", this.ContentLength);
            parameters.Add("content-md5", this.ContentMD5);
            parameters.Add("slice-md5", this.SliceMD5);
            parameters.Add("content-crc32", this.ContentCrc32);
            parameters.Add("ondup", this.Ondup);
            return parameters;
        }

        public void Validate()
        {
            RequestValidator.ValidateRequired("path", this.Path);
            RequestValidator.ValidateMaxLength("path", this.Path, 1000);
            RequestValidator.ValidateRequired("content-length", this.Path);
            RequestValidator.ValidateRequired("content-md5", this.Path);
            RequestValidator.ValidateRequired("slice-md5", this.Path);
            //RequestValidator.ValidateRequired("content-crc32", this.Path);
        }

        #endregion

    }
}
